package cn.com.oidreams.aliyun.robot.entity;

import cn.com.oidreams.aliyun.robot.enums.DingTalkEnum;
import cn.com.oidreams.common.annotations.Required;
import cn.com.oidreams.common.enums.YesOrNoEnum;
import lombok.Data;

/***
 ** @category 请用一句话描述这个类的用途
 ** @author qing.yunhui
 ** @email: qingyh@glodon.com
 ** @createTime: 2021-11-24 16:16
 **/
@Data
public class ActionCardMsgRequest extends BaseRequest{

    @Required(errorMsg = "actionCard不能为空",remark="actionCard",classParse = true)
    private ActionCard actionCard;

    public ActionCardMsgRequest(ActionCard actionCard,String secret) {
        super.setMsgtype(DingTalkEnum.MSG_TYPE.ACTION_CARD.getCode());
        this.actionCard = actionCard;
        super.setTimestamp(System.currentTimeMillis());
        super.setSecret(secret);
    }

    @Data
    public static class ActionCard{
        @Required(errorMsg = "首屏会话透出的展示内容不能为空",remark="首屏会话透出的展示内容",classParse = false)
        private String title;
        @Required(errorMsg = "消息内容不能为空",remark="markdown格式的消息",classParse = false)
        private String text;
        @Required(errorMsg = "按钮的标题不能为空",remark="单个按钮的标题，注意:(设置此项和singleURL后，btns无效)。",classParse = false)
        private String singleTitle;
        @Required(errorMsg = "跳转的URL不能为空",remark="点击消息跳转的URL，打开方式如下：移动端(在钉钉客户端内打开)，PC端(默认侧边栏打开)",classParse = false)
        private String singleURL;
        // --------------- 非必填 ---------------
        /**
         * <p>按钮排列方向(0:按钮竖直排列、1:按钮横向排列)</p>
         * */
        private int btnOrientation;
        // --------------- 构建函数 ---------------
        public ActionCard(String title, String text, String singleTitle, String singleURL){
            this(title,text,singleTitle,singleURL, YesOrNoEnum.NO.getKey());
        }
        public ActionCard(String title, String text, String singleTitle, String singleURL, int btnOrientation) {
            this.title = title;
            this.text = text;
            this.singleTitle = singleTitle;
            this.singleURL = singleURL;
            this.btnOrientation = btnOrientation;
        }
    }
}
